<?php
namespace pfp\lib {

    \defined('_JEXEC') or die('Restricted access');

    /**
     * Description of pfp\lib\Watcher
     *  DO NOT expose Watcher to applications, it is only for pfp functions...
     * @todo 
     * 
     * @author George Zeakis<zeageorge@google.com>
     * 
     */
    class Watcher {

        protected static $_objectsToWatch = array();

        protected static $_instance = \NULL;

        /**
         * we don't permit an explicit call of the constructor! (like $v = new Singleton()) 
         */
        protected function __construct(){}

        /**
         * we don't permit cloning the singleton (like $x = clone $v) 
         */
        protected function __clone(){}

        /**
         * 
         * @return pfp\lib\Watcher
         */
        public static function getInstance(){
          if( self::$_instance === \NULL ) { self::$_instance = new self(); }

          // scan folders, find and register the Actions...

          return self::$_instance;
        }

        /**
         * 
         * @param mix $what What to watch
         * @param mix $of   The object that $what belongs to
         */
        public static function start_watching(&$what, &$of=\NULL){
            if( self::$_instance === \NULL ) { self::getInstance(); }
            // should we use the tic function of php to watch the $what ?
            // check: http://php.net/manual/en/control-structures.declare.php
            //        http://www.php.net/manual/en/function.register-tick-function.php
            //        http://www.php.net/manual/en/function.unregister-tick-function.php
            //
            //
        }

        public static function stop_watching(&$what){
            if( self::$_instance === \NULL ) { self::getInstance(); }
        }

        public static function act(){
            if( self::$_instance === \NULL ) { self::getInstance(); }
        }

    }
}
?>
